<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="cn">

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <title>
            <?php if(isset($meta_title)): echo ($meta_title); ?> - <?php echo C('WEB_SITE_TITLE');?> - <?php echo C('WEB_SITE_SLOGAN');?>
                <?php else: ?> 
                <?php echo C('WEB_SITE_TITLE');?> - <?php echo C('WEB_SITE_SLOGAN'); endif; ?>
        </title>

        <meta name="description" content=" <?php echo C('WEB_SITE_DESCRIPTION');?>" />

        <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>

        <script src="/Public/jquery/jquery-1.11.1.js"></script>

        <script src="/Public/front/js/common.js"></script>

        <!-- basic styles -->
        <!--首页轮播和商品多图js-->
        <link rel="stylesheet" href="/Public/front/css/flexslider.css" />

        <link rel="stylesheet" href="/Public/front/css/comman.css" />

        <link rel="stylesheet" href="/Public/front/css/style.css" />

        <link rel="stylesheet" href="/Public/front/css/milk.css" />

        <link rel="stylesheet" href="/Public/front/css/user2015.css" />

        <link rel="stylesheet" href="/Public/front/css/tpl.css" />

        <link rel="stylesheet" href="/Public/front/css/style12.css" />

        <script src="/Public/front/js/jquery.min.js"></script> 

        <script src="/Public/front/js/jquery_dialog.js"></script>

        <!--会话框js和css-->
        <link rel="stylesheet" href="/Public/remind/css/alert.css" />

        <script src="/Public/remind/js/jquery.alerts.js"></script>
        <!--会话框js和css end-->

        <script src="/Public/front/js/jquery.flexslider-min.js"></script>

        <script src="/Public/front/js/common.js"></script>

        <script src="/Public/front/js/time.js"></script>

        <script src="/Public/front/js/user.js"></script>

        <!--调用微信js接口 2016-7-22 17:57:35-->
        <!--<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>-->

        <script type="text/javascript">
            //通过config接口注入权限验证配置
            wx.config({
                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。

                appId: '<?php echo ($jsappid); ?>', // 必填，公众号的唯一标识

                timestamp: '<?php echo ($jstimestamp); ?>', // 必填，生成签名的时间戳

                nonceStr: '<?php echo ($jsnonceStr); ?>', // 必填，生成签名的随机串

                signature: '<?php echo ($jsSign); ?>', // 必填，签名

                jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage"] // 必填，需要使用的JS接口列表
            });
            //通过ready接口处理成功验证
            wx.ready(function () {

                wx.onMenuShareTimeline({
                    title: "<?php echo C('WEB_SITE_TITLE');?> - <?php echo C('WEB_SITE_SLOGAN');?>", // 分享标题

                    link: "<?php echo C('WEB_SITE_DOMAIN');?>/index.php?s=/WeChat/Member/send_score.html&fxidentify=<?php echo ($fxidentify); ?>", // 分享链接

                    imgUrl: "<?php echo C('WEB_SITE_DOMAIN'); echo get_logo(C('WEB_SITE_LOGO'));?>", // 分享图标

                    trigger: function (res) {
                        // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
                        //alert('用户点击分享到朋友圈');
                    },
                    success: function (res) {
                        //alert(res.title);
                        //alert('已分享');
                    },
                    cancel: function (res) {
                        //alert('已取消');
                    },
                    fail: function (res) {
                        //alert(JSON.stringify(res));
                    }

                });

                wx.onMenuShareAppMessage({
                    title: "<?php echo C('WEB_SITE_TITLE');?> - <?php echo C('WEB_SITE_SLOGAN');?>", // 分享标题

                    link: "<?php echo C('WEB_SITE_DOMAIN');?>/index.php?s=/WeChat/Member/send_score.html&fxidentify=<?php echo ($fxidentify); ?>", // 分享链接

                    imgUrl: "<?php echo C('WEB_SITE_DOMAIN'); echo get_logo(C('WEB_SITE_LOGO'));?>", // 分享图标

                    desc: "<?php echo C('WEB_SITE_DESCRIPTION');?>", // 分享描述

                    trigger: function (res) {
                        // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
                        //alert('用户点击发送给朋友');
                    },
                    success: function (res) {
                        //alert('已分享');
                    },
                    cancel: function (res) {
                        //alert('已取消');
                    },
                    fail: function (res) {
                        //alert(JSON.stringify(res));
                    }
                });

            });

            wx.error(function (res) {
                // alert(res);
                // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。

            });
        </script>

    </head>

    <body>


<div id="home">

    <div id="header">

        <div style="height:28px; padding-top:10px; background:url(/Public/Front/images/xy.png) 10px 8px no-repeat" class="logo"><span onclick=" history.go(-1);">&nbsp;</span></div>

        <div class="shoptitle"><span>积分转赠</span></div>

        <div class="logoright" style="z-index: 1000">

    <div>

        <a onclick="ajax_show_menu()" href="javascript:;"></a>

        <div class="showmenu">

            <p>
                <a href="<?php echo U('WeChat/Index/index');?>">返回首页</a>
            </p>

            <p>
                <a href="<?php echo U('WeChat/Member/center');?>">会员中心</a>
            </p>

            <p>
                <a href="<?php echo U('WeChat/Member/order');?>">我的订单</a>
            </p>

            <p>
                <a href="<?php echo U('WeChat/Cart/index');?>">购&nbsp;物&nbsp;车</a>
            </p>

            <p style="border:none">
                <a href="javascript:;" onclick="window.location.reload();">刷新页面</a>
            </p>

        </div>

    </div>

</div>

<script type="text/javascript">
    function ajax_show_menu() {
        $(".showmenu").toggle(500);
    }
</script>

    </div>

</div>

<div style="display: none;" id="opquyu"></div>

<div id="opquyubox" style="display:none">
    
    <div style="line-height:26px;">
        
        <?php if(!empty($category)): if(is_array($category)): $i = 0; $__LIST__ = $category;if( count($__LIST__)==0 ) : echo "暂时没有数据" ;else: foreach($__LIST__ as $key=>$c): $mod = ($i % 2 );++$i;?><h2 style="border-bottom:1px solid #ededed;"><a href="<?php echo U('WeChat/Category/index',array('id'=>$c['id']));?>"><?php echo ($c["title"]); ?></a></h2><?php endforeach; endif; else: echo "暂时没有数据" ;endif; endif; ?>
        
    </div>
    
    <div style=" height:45px;"></div>
    
</div>

<!--<script type="text/javascript">
    
    $(document).ready(function ($) {
        
        $('#opquyu').click(function () {
            
            $(this).hide();
            
            $("#opquyubox").hide();
            
        });

    });
    
</script>-->

<style type="text/css">

    .tx-top{
        margin: 0 10px;
    }
    .tx-top p{
        padding: 15px 0;
    }
    .tx-top span{
        color: #FF0000;
    }

    .tx-content{
        padding: 0 10px;
        margin-bottom: 100px;
    }
    .tx-content li{
        border: 1px solid #eaeaea;
        border-radius: 5px;
        padding: 10px 0;
        position: relative;
        margin-bottom: 20px;
    }
    .tx-content input{
        color: #999999;
        padding-left: 10px;
        font-size: 16px;

        line-height: 40px;
    }

    .tips{
        line-height: 30px;
        color: #FF0000;
    }


    .tx-button{
        position: fixed;
        bottom:55px;
        width: 100%;
        max-width: 620px;
        min-width: 320px;
    }
    .tx-button ul{
        overflow: hidden;
        width: 100%;
    }
    .tx-button li{
        width: 46%;
    }
    .tx-button input{
        border-radius: 5px;
        padding: 10px 0;
        width: 100%;
        background: #328c09;
        color: #FFFFFF;
        font-size: 18px;
    }

</style>
<script type="text/javascript">

    var balance = "<?php echo ($balance); ?>";

//    检测会员信息正确性
    function check_member($type) {

        var id = $("input[name='ruser_id' ]").val().replace(/\s/g, "");

        if ((id == '') || (!$.isNumeric(id))) {

            jAlert('会员编码输入有误！', '警告', function () {

                return false;
            });

            return false;
        }

        if ($type == 1) {

            return true;
        }

        $.post('<?php echo U("Member/check_member");?>', {"id": id, "identify": 'store'}, function (data) {
            console.log();

            var status = data.status;

            var msg = '';

            if (status) {

                msg = '会员编号【' + data.info.id + '】,昵称【' + data.info.nickname + '】';

                jAlert(msg, '确认信息');

//                alert($("input[name='send_submit']").val());

                $("input[name='send_submit']").attr("disabled", false);
            } else {

                jAlert(data.info, '提示');
            }

        }, 'json');
    }

//检测积分信息正确性
    function  check_score() {

        var t = /^\d+(\.\d+)?$/;

        var $score = $("input[name='total' ]").val().replace(/\s/g, "");

        var aa = t.test($score);

        if (!aa || ($score <= 0)) {

            jAlert('转赠积分必须是正数!', '警告');
            return false;
        }

        return $score;
    }

//   操作button
    function  form_submit($val) {

        //表单提交
        if ($val == '1') {

//            console.log($("form").serialize());return;

            var score = $('input[name="total"]').val();

            if (!check_score(score)) {

                jAlert('转赠积分必须是正数!', '警告');
                return;
            }

            if (score > balance) {

                jAlert('余额不足!', '警告');
                return;
            }

            if (!check_member(1)) {
                return;
            }

            $('form').submit();

        } else if ($val == '2') {

            window.location.href = "<?php echo U('Member/sendscore_list');?>";
            
        } else {
            return;
        }

    }
</script>

<div id="main" style="background:#fff;">

    <header class="tx-top">

        <p>当前账户余额&nbsp;:<span><?php echo ($balance); ?></span></p>

    </header>

    <form id="form_sendscore"  action="<?php echo U('Member/send_score');?>"  method="post">


        <input type="hidden" name="user_id" value="<?php echo ($user_id); ?>" />

        <input type="hidden" name="member_balance" value="<?php echo ($balance); ?>" />


        <nav class="tx-content">
            <ul>

                <li>

                    <span style="padding: 0 10px;border-right: 1px solid #eaeaea;">转赠积分</span>

                    <input type="text" name="total" value="转赠数值:50"  onblur="if (value == '') {
                                value = '转赠数值:50'
                            } else {

                                return check_score();
                            }" onfocus="if (value == '转赠数值:50') {
                                        value = ''
                                    }" />

                    <!--<span style="position: absolute;right: 10px;">元</span>-->

                </li>

                <li>

                    <span style="padding: 0 10px;border-right: 1px solid #eaeaea;">收款会员</span>

                    <input type="text" name="ruser_id" value="会员编号:666"  onblur="if (value.replace(/\s/g, '') == '') {
                                value = '会员编号:666';

                            } else {

                                return check_member();
                            }" onfocus="if (value.replace(/\s/g, '') == '会员编号:666') {
                                        value = '';
                                    }" />

                    <!--                <select style="border: none; color: #999999; font-size: 16px;padding-left: 5px;">
                                        <option>河南经济广播</option>
                                        <option>河南经济广播</option>
                                        <option>河南经济广播</option>
                                    </select>-->
                </li>

                <li>

                    <span style="padding: 0 10px;border-right: 1px solid #eaeaea;">转赠备注</span>

                    <input type="text" name="remark" value=""  placeholder='留下备注'  />
                </li>

                <!--<a href="javascript:;" style="text-align: center; padding-bottom: 20px;width: 100%; display: block;text-decoration: underline;">管理体现方式</a>-->

            </ul>
            <div class="tips">
                <p>提示：</p>
                <p>积分转赠立即到帐，不可撤销，请认真确认</p>
            </div>

        </nav>

        <div class="tx-button">
            <ul>
                <li style="float: left;"><input type="button" name="sendrecord" onclick ='form_submit("2")' value="转赠记录" style='background:#aaa'/></li>

                <li style="float: right;"><input type="button" name="sendscore" onclick='form_submit("1")' value="立即转赠"/></li>
            </ul>
        </div>

    </form>

</div>

<div style="-webkit-transform:translate3d(0,0,0)" class="top_bar">
    <nav>
        <ul class="top_menu" id="top_menu">
            <li class="li1">
                <a  href="<?php echo U('Index/index');?>">
                    <label>首页</label>
                </a>
            </li>
            <li class="li2">
                <a  onclick="ajaxopquyu()">
                    <label>分类</label>

                </a>
            </li>
            <li class="li4">
                <a  href="<?php echo U('WeChat/Member/center');?>">
                    <label>会员</label>
                </a>
            </li>
            <li class="li5">
                <a style="height:56px; padding:0px"  href="<?php echo U('WeChat/Cart/index');?>">
                    <span style="width:30px; height:32px; display:block; margin:0px auto">
                        <b>
                            <em style="display:block" value="1" class="mycarts" id="buy_price"><?php echo ($cart_count); ?></em>
                        </b>
                    </span>
                    <label>购物车</label>
                </a>
            </li>    
        </ul>
    </nav>
</div>

<style type="text/css">
    body { padding-bottom:60px !important; }
    .top_menu li b {width: 38px;height: 20px;line-height: 17px;display: block;color: #fff;text-align: center;font-size: 12px;}
    .top_menu li b em {padding:0px 3px 0px 3px;border-radius: 100%;text-align: center;background-color: #32a000;display: block;position: absolute;z-index: 9999;margin-top: -10px;margin-left: 22px;}
    user agent stylesheeti, cite, em, var, address, dfn {font-style: italic;}

    .top_menu li.li2 a.butt-cart{display: inline-block;font-size: 15px;width: 90%;height: 40px;line-height: 38px;margin: 6px auto 5px auto;padding: 0;color: #FFF;border-radius: 3px;background:#32a000;}
    .top_menu li.li4 a.butt-buy {display: inline-block;font-size: 15px;width: 90%;height: 40px;line-height: 38px;margin: 6px auto 5px auto;padding: 0;color: #FFF;border-radius: 3px;background:#ff6400;}
</style>
</body>
</html>